package com.liruo.treasureattic.service.user.controller;

import com.liruo.treasureattic.common.httpmsg.result.BaseResponse;
import com.liruo.treasureattic.common.model.dto.user.*;
import com.liruo.treasureattic.common.model.vo.user.UserVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author:liruo
 * @Date:2023-02-15-10:58:11
 * @Desc
 */
@RequestMapping("/user")
public interface UserController {
    @PostMapping("/register/precheck")
    BaseResponse<Boolean> registerPreCheck(@RequestBody UserRegisterPreCheckReq preCheckReq);

    @ApiOperation(
            value = "邮件验证码",
            notes = "仅限1分钟，最大错误次数3次的验证码请求接口"
    )
    /**
     * @param codeReq
     * @return
     */
    @PostMapping("/register/email/code")
    BaseResponse<CodeResp> limit3Code(@RequestBody CodeReq codeReq);

    /**
     * 注册前先要求用户填写完再请求/register/precheck, 再请求/user/register/email/code
     * avatar没有会设为默认的
     * @return
     */
    @PostMapping("/register/email")
    BaseResponse<Long> registerByEmail(UserRegisterReq userRegisterReq);


    /**
     * 简单处理为同时登录会更改sessionId，挤掉之前的登录
     * @param loginReq
     * @return
     */
    @PostMapping("/login/up")
    BaseResponse<UserVo> loginByEmail(HttpServletRequest request, @RequestBody UserLoginReq loginReq);

    @PostMapping("/{id}")
    BaseResponse<UserVo> getUserVo(@PathVariable("id") Long id);

    @PostMapping("/update")
    BaseResponse<UserVo> updateUserById(@RequestBody UserUpdateReq userUpdateReq);
}
